package cn.jxufe.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import cn.jxufe.bean.Message;
import cn.jxufe.utils.FileSaver;

/***
 * 文件上传
 * @author Banner
 *
 */
@Controller
@RequestMapping("file")
public class FileController {
	/***
	 * 保存用户头像.
	 * @param request 请求
	 * @param uploadFile 已上传文件内容
	 * @return Message 消息实体
	 */
    @RequestMapping(value="saveHeadImg", produces=MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    public Message saveHeadImg(HttpServletRequest request, 
    		@RequestParam("filePathName") MultipartFile uploadFile){
    	System.out.println("filePathName = " + uploadFile.getOriginalFilename());
        return FileSaver.save("images/headImages/", request, uploadFile);
    }   
}
